<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <!-- 導入 -->
    <script src="./5-common.js"></script>
    <script>
        // 測試get和post請求

        // 1.get請求 - 無參
        itcast({
            method:'get',
            url:'http://www.liulongbin.top:3009/api/getbooks',
            success:function(res){
                console.log(res);
            }
        })

        // 2.get請求 - 有參
        itcast({
            method:'get',
            url:'http://www.liulongbin.top:3009/api/getbooks',
            params:{
                id:2
            },
            success:function(res){
                console.log(res);
            }
        })

        // 3.post請求 - 字符串類型
        itcast({
            method:'post',
            url:"http://www.liulongbin.top:3009/api/addbook",
            data:'bookname=一座城池&author=韓寒&publisher=上海人民出版社',
            success:function(res){
                console.log(res);
            }
        })

        // 4.post請求 - 對象類型
        itcast({
            method:'post',
            url:"http://www.liulongbin.top:3009/api/addbook",
            data:{bookname:'三重門',author:'韓寒',publisher:'上海人民出版社'},
            success:function(res){
                console.log(res);
            }
        })
    </script>
</body>
</html>